package com.example.controller.comment;

import com.example.pojo.Comment;
import com.example.service.comment.CourseCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: demo
 * @description: 课程评论
 * @author: yc
 * @create: 2023-02-02 15:12
 **/
@CrossOrigin
@RestController
@RequestMapping("/courseComment")
public class CourseCommentController {
    @Autowired
    private CourseCommentService service;

    /**
     * @Description: 课程评论列表
     * @Param: * @param
     * @return: java.util.List<com.example.pojo.Comment>
     * @Author: yc
     * @Date: 2023/2/2 18:27
     */
    @RequestMapping("getCommentList")
    public List<Comment> getCommentList(){
        List<Comment> commentList = service.getCommentList();
        return commentList;
    }

    /**
     * @Description: 根据评论状态查询
     * @Param: * @param state
     * @return: java.util.List<com.example.pojo.Comment>
     * @Author: yc
     * @Date: 2023/2/2 16:58
     */
    @RequestMapping("getCommentState")
    public List<Comment> getCommentState(Integer state,String account,String nickname){
        List<Comment> commentState = service.getCommentState(state,account,nickname);
        return commentState;
    }


    /**
     * @Description: 历史评论次数
     * @Param: * @param comment
     * @return: java.util.Map<java.lang.Object,java.lang.Object>
     * @Author: yc
     * @Date: 2023/2/5 18:39
     */
    @RequestMapping("getLiFrequency")
    public Map<Object, Object> getLiFrequency(Comment comment){
        Map<Object, Object> map = new HashMap<>();
        map.put("c",service.getLiFrequency(comment));
        return map;
    }

    /**
     * @Description: 历史评论人数
     * @Param: * @param comment
     * @return: java.util.Map<java.lang.Object,java.lang.Object>
     * @Author: yc
     * @Date: 2023/2/5 18:38
     */
    @RequestMapping("getLiPeople")
    public Map<Object, Object> getLiPeople(Comment comment){
        Map<Object, Object> map = new HashMap<>();
        map.put("c",service.getLiPeople(comment));
        return map;
    }

    /**
     * @Description: 今日评论次数
     * @Param: * @param comment
     * @return: java.util.Map<java.lang.Object,java.lang.Object>
     * @Author: yc
     * @Date: 2023/2/5 18:38
     */
    @RequestMapping("getJinFrequency")
    public Map<Object, Object> getJinFrequency(Comment comment){
        Map<Object, Object> map = new HashMap<>();
        map.put("c",service.getJinFrequency(comment));
        return map;
    }


    /**
     * @Description: 今日评论人数
     * @Param: * @param comment
     * @return: java.util.Map<java.lang.Object,java.lang.Object>
     * @Author: yc
     * @Date: 2023/2/5 18:38
     */
    @RequestMapping("getJinPeople")
    public Map<Object, Object> getJinPeople(Comment comment){
        Map<Object, Object> map = new HashMap<>();
        map.put("c",service.getJinPeople(comment));
        return map;
    }

    /**
     * @Description: 通过
     * @Param: * @param comment
     * @return: int
     * @Author: yc
     * @Date: 2023/2/5 18:40
     */
    @PostMapping("getTongGuo")
    public int getTongGuo(Comment comment){
        int tongGuo = service.getTongGuo(comment);
        return tongGuo;
    }

    /**
     * @Description: 拦截
     * @Param: * @param comment
     * @return: int
     * @Author: yc
     * @Date: 2023/2/5 18:41
     */
    @RequestMapping("getLanJie")
    public int getLanJie(Comment comment){
        int lanJie = service.getLanJie(comment);
        return lanJie;
    }

    /**
     * @Description: 删除
     * @Param: * @param comment
     * @return: void
     * @Author: yc
     * @Date: 2023/2/5 18:41
     */
    @RequestMapping("delComment")
    public void delComment(Integer id){
        service.delComment(id);
    }
}
    